<template>
	<view class="code_input">
		<view class="close" @click="close">
			<image src="@/static/images/close.png"></image>
		</view>
		<view class="title">交易密码</view>
		<view class="desc">
			<text>为保证您的账户安全，请输入交易密码</text>
			<view @click.stop="router('/pages/login/setting')">忘记密码？</view>
		</view>
		<view class="code_view">
			<uv-code-input mode="box" color="#fff" dot @finish="finish"></uv-code-input>
		</view>
		<view class="submit" @click="submit">确认购买</view>
	</view>
</template>

<script setup>
	import {
		onUnmounted
	} from "vue";
	const emit = defineEmits(["close", "submit"]);
	import useBase from "@/hooks/useBase.js";
	const {
		router
	} = useBase();
	const close = () => emit("close");
	let value;
	const finish = (e) => value = e;
	const submit = () => emit("submit", value);
	onUnmounted(() => value = null);
</script>

<style scoped lang="scss">
	.code_input {
		padding: 40rpx 60rpx;
		box-sizing: border-box;
		background: #2F2F2F;
		position: relative;

		.close {
			position: absolute;
			right: 30rpx;
			top: 20rpx;
			z-index: 2;

			image {
				width: 44rpx;
				height: 44rpx;
			}
		}

		.title {
			color: #FFFFFF;
			font-size: 32rpx;
			font-weight: bold;
		}

		.desc {
			padding: 38rpx 0 34rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			align-items: center;

			text {
				color: #999999;
				font-size: 28rpx;
			}

			view {
				color: #FFFFFF;
				font-size: 28rpx;
				font-weight: bold;
			}
		}

		.code_view {
			display: flex;
			justify-content: center;
		}

		.submit {
			width: 620rpx;
			height: 88rpx;
			line-height: 88rpx;
			text-align: center;
			color: #111111;
			font-size: 28rpx;
			font-weight: bold;
			border-radius: 20rpx;
			margin-top: 75rpx;
			background: #DDF247;
		}
	}
</style>